package com.lixiaoyi.ems.entity;

/**
 * @Author 李小毅
 * @Description
 * @Date 2022-05-18
 */

public class Page {

    private Integer pageNum;

    private Integer pageSize;

    private Integer totalCounts;

    private Integer totalPages;

    private Integer startRows;

    public Page(Integer pageNum) {
        this(pageNum,5);
    }

    public Page(Integer pageNum, Integer pageSize) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        //得到起始行
        this.setStartRows((pageNum - 1) * pageSize);
    }


    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalCounts() {
        return totalCounts;
    }

    public void setTotalCounts(Integer totalCounts) {
        this.totalCounts = totalCounts;
        //得到总页数
        //this.setTotalPages(this.totalCounts % this.pageSize == 0?this.totalCounts / this.pageSize : this.totalCounts / this.pageSize + 1);
        this.setTotalPages(totalCounts % pageSize == 0? totalCounts / pageSize:totalCounts / pageSize + 1);

    }

    public Integer getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
    }

    public Integer getStartRows() {
        return startRows;
    }

    public void setStartRows(Integer startRows) {
        this.startRows = startRows;
    }

    @Override
    public String toString() {
        return "Page{" +
                "pageNum=" + pageNum +
                ", pageSize=" + pageSize +
                ", totalCounts=" + totalCounts +
                ", totalPages=" + totalPages +
                ", startRows=" + startRows +
                '}';
    }
}
